/* File Created: April 8, 2013 */
var jsonContent = 'application/json; charset=utf-8',
	dataSrv = {
		
        getJson: function (action, data, subData) {
            
            /* add parameter */
            var dataString = "";
			for (i in data) {
                if (dataString == ""){
                    /* is first time */
                    dataString += i + "=" + data[i];
                }
                else
                {
                    dataString += "&" + i + "=" + data[i];
                }
				
			}
            if (subData != undefined){
                dataString += "&" + subData;
            }
            
			return $.ajax({
                          beforeSend : function(req) {
                              req.setRequestHeader('Authorization', 'Bearer ' + strAccessToken);
                          },
                          type: 'GET',
                          url:localStore.get(strDomainKey) + action,
                          data: dataString,
                          dataType: 'json',
                          cache: false,
                          timeout: 30000
                          });
        },
        postJson: function (action, data) {
            return $.ajax({
                          beforeSend : function(req) {
                              req.setRequestHeader('Authorization', 'Bearer ' + strAccessToken);
                          },
                          type: 'POST',
                          url: localStore.get(strDomainKey) + action + '?',
                          data: JSON.stringify(data),
                          contentType: jsonContent,
                          dataType: 'json',
                          cache: false,
                          timeout: 30000
                          });

        },
        postJsonLogin: function (action, data) {
            var dataString = "";
			for (i in data) {
				dataString += i + "=" + data[i] + "&";
			}
            return $.ajax({
                          beforeSend : function(req) {
                            req.setRequestHeader('Authorization', 'Basic ' + strAuthorization);
                          },
                          type: 'POST',
                          url: localStore.get(strDomainKey)+action,
                          data: dataString,
                          contentType: 'application/x-www-form-urlencoded',
                          dataType: 'json',
                          cache: false,
                          timeout: 30000
                          });
            
        }
	};
